<template>
  <el-form label-position="top" :model="form" :rules="rules" ref="form">
    <el-form-item :label="`${$t('common.fields.partName.displayName')}:`">
      <el-input type="text" placeholder="" :value="formdata.sparepartRepertory&&formdata.sparepartRepertory.sparepart&&formdata.sparepartRepertory.sparepart.name" readonly></el-input>
    </el-form-item>
    <el-form-item :label="`${$t('task.detail.components.applyTime')}:`">
      <el-input type="text" placeholder="" :value="formdata.propserTime" readonly></el-input>
    </el-form-item>
    <el-form-item :label="`${$t('part.field24')}:`">
      <el-input type="text" placeholder="" :value="userName" readonly></el-input>
    </el-form-item> 
     <el-form-item :label="`${$t('part.field25')}:`" prop="content">
      <el-input type="textarea" :placeholder="$t('part.tips46', {num:500})" :autosize="{ minRows: 2, maxRows: 5}" v-model="form.content"></el-input>
    </el-form-item>
  </el-form>
</template>

<script>
import { t } from '@src/locales';

export default {
  name: 'part-backstock-form',
  inject: ['initData'],
  props: {
    formdata: {
      type: Object,
      default: () => ({})
    },
    sparepartConfig: {
      type: Object,
      default: () => ({})
    },
    repertory: {
      type: Array,
      default: () => []
    },
    userId: '',
    userName: ''
  },
  data(){
    return {
      form: {
        type: '',
        number: '',
        content: ''
      },
      numberValidateForm: {
        number: '',
        repertory: ''
      },
      rules: {
        content: [
          {required: true, message: t('part.tips47')},
          {max: 500, message: t('part.tips48', {num:500})}
        ],
        number:[
          { required: true, message: t('part.tips49')}
        ]
      }
    }
  },
  methods: {
    async pack(){
      try {
        let isSucc = await this.$refs.form.validate();
        if(isSucc){
          return {
            id : this.formdata.id,
            remark : this.form.content
          }
        }
      } catch (error) {
        console.log(error)
      }

      return null;
    },
  },
}
</script>

<style lang="scss">
.el-form-item{
  margin-bottom: 0
}
.el-form-item__error{
  position: relative;
}
#outType{
  width: 100%;
  height: 34px;
}
</style>